<template>
	<view>
		<view class="page page-bottom-bar newPrescript">
			<!-- 诊断信息 -->
			<view class="part2 box-shadow">
				<view class="font14">诊断</view>
				<view class="txt-textarea font-ef9140">{{info.diagnosis_proposal}}</view>
			</view>
			<!-- 药品信息 -->
			<view class="part3 box-shadow">
				<view class="prescript-list drugs-box">
					<block v-for="(item, index) in info.goods_list" :key="index">
						<view class="item">
							<view class="part2">
								<view class="name font14">{{item.goods_name}} *{{item.number}}</view>
								<view class="font12 font-969696">用法用量：{{item.frequency}}，{{item.consumption}}，{{item.usage}}</view>
							</view>
						</view>
					</block>
				</view>
			</view>
		</view>
		<!-- 按钮 -->
		<view class="fix-bottom-btn flex-row-center">
			<view class="btn flex-row-center font-ffffff font15" @click="onEdit">使用该处方</view>
		</view>
	</view>
</template>

<script>
	import topBar from "@/components/ComTopBar.vue";
	export default {
		components: { topBar },
		data() {
			return {
				cate: '',
				consultation_id: '',
				type: '',
				familyId: '', // 就诊人的id
				doctorId: '', // 医生id
				prescriptId: '', // 处方id
				info: {}
			}
		},
		onLoad(options) {
			this.cate = options.cate
			this.consultation_id = options.consultation_id
			this.type = options.type
			this.familyId = options.familyId
			this.doctorId = options.doctorId
			this.prescriptId = options.id
			
			this.$Http({
				url: 'detailsCommonlyUsedPrescription',
				data: {doctor_prescription_id: options.id}
			}).then(res => {
				if (res.code == 1) {
					this.info = res.data
				} else {
					uni.showToast({ title: res.msg, icon: 'none' })
				}
			})
		},
		methods: {
			// 编辑(使用该处方)
			onEdit () {
				if(this.cate){
					uni.redirectTo({
						// url:  '/pagesA/prescript/newPrescript?familyId=' + this.familyId + '&doctorId=' + this.doctorId + '&prescriptId=' + item.id
						url:  '/pagesA/prescript/newPrescript?cate='+this.cate+'&consultation_id='+this.consultation_id+'&familyId=' + this.familyId + '&doctorId=' + this.doctorId + '&prescriptId=' + this.prescriptId + '&type=' + this.type
					})
				}else{
					uni.navigateTo({
						// url:  '/pagesA/prescript/newPrescript?familyId=' + this.familyId + '&doctorId=' + this.doctorId + '&prescriptId=' + item.id
						url:  '/pagesA/prescript/newPrescript?cate='+this.cate+'&consultation_id='+this.consultation_id+'&familyId=' + this.familyId + '&doctorId=' + this.doctorId + '&prescriptId=' + this.prescriptId + '&type=' + this.type
					})
				}
			}
		}
	}
</script>

<style lang="less">
	@import url("style.less");
</style>
